package com.eliza.music.model.vm

import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
import com.eliza.music.model.dao.SongDao
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import javax.inject.Inject


data class PlayingSetting(
    val animationKeyframesDur: Int = 100, // 0.1s
    var isPlaying: MutableState<Boolean> = mutableStateOf(false),
    var showPlayingPage: MutableState<Boolean> = mutableStateOf(false),
    var showPlaylist: MutableState<Boolean> = mutableStateOf(false),
)

@HiltViewModel
class PlayingSettingVm @Inject constructor(val songDao: SongDao) : ViewModel() {

    private var _uiSetting = MutableStateFlow(PlayingSetting())
    val setting: StateFlow<PlayingSetting> = _uiSetting.asStateFlow()

    fun showPlaylist(show: Boolean) {
        _uiSetting.value.showPlaylist.value = show
    }

    fun showPlayingPage(show: Boolean) {
        _uiSetting.value.showPlayingPage.value = show
    }

    fun Playing(show: Boolean) {
        _uiSetting.value.isPlaying.value = show
    }

}